package com.tencent.ncnnyolox.net

import com.tencent.ncnnyolox.basemodule.NetWorkManager
import com.tencent.ncnnyolox.net.bean.ChatPhraseAddDTO
import com.tencent.ncnnyolox.net.bean.ChatPhraseUpdateDTO
import com.tencent.ncnnyolox.net.bean.request.ChatHistoryAddDTO
import com.tencent.ncnnyolox.net.bean.request.ChatHistoryRequest

/**
 * <pre>
 *     author : yh
 *     e-mail : xxx@xx
 *     time   : 2023/12/22
 *     desc   :
 * </pre>
 */
class ApiNetWork {
    private val mService by lazy {
        NetWorkManager.getInstance().create(ApiService::class.java)
    }

//    suspend fun login(bean: LoginRequestBean)
//            =NetWorkManager.getInstance().create(ApiService::class.java).login(bean.biz_content,bean.format,bean.method,bean.sign,bean.sign_type,bean.timestamp,bean.version)
//
//    suspend fun checkLogin(token:String)= NetWorkManager.getInstance().create(LoginService::class.java).check(token)


    suspend fun getCommonWord(memberId:String)= mService.getCommonWord(memberId)

    suspend fun updateCommonWord(bean:ChatPhraseUpdateDTO)=mService.updateCommonWord(bean)

    suspend fun deleteCommonWord(id:Long)=mService.deleteCommonWord(id)

    suspend fun addCommonWord(bean:ChatPhraseAddDTO)=mService.addCommonWord(bean)

    suspend fun getLabelPhrase()=mService.getPhraseLabel()

    suspend fun addRecord(bean:ChatHistoryAddDTO)=mService.addRecord(bean)


    suspend fun getChatResponseRecord(bean:ChatHistoryRequest)=mService.getChatRecord(bean)
    companion object {
        @Volatile
        private var apiNetWork: ApiNetWork? = null

        fun getInstance() = apiNetWork ?: synchronized(this) {
            apiNetWork ?: ApiNetWork().also {
                apiNetWork = it
            }
        }
    }
}